/**
 * Created by Xavier on 02/09/14.
 */
function enregIncident(){
    var typeMouv="6";
    var idPal=document.getElementById("idPal").value;
    var qteArticle=document.getElementById("qteArticle").value;
    var idIncident=document.getElementById("lstIncident").value;
//    var idFournisseur=document.getElementById("idFournisseur").value;
    var idArticleFour=document.getElementById("idArticleFour").value;
    var idzonedepart= document.getElementById("idzonedepart").value;
    if(idIncident!=0){
        $.ajax({
            type:"post",
            url:"/listeTaches/declareincident",
            datatype:"text",
            contentType:"application/x-www-form-urlencoded ; charset=UTF-8",
            data:"ajxTypeMouv="+typeMouv+"&ajxIdPal="+idPal+"&ajxqteArt="+qteArticle+"&ajxIdIncident="+idIncident+"&ajxIdArticleFour="+idArticleFour+"&ajxZoneDepart="+idzonedepart,
            success:function(response){
                var rep = response;
                console.log(rep);
                if(rep=="Mouvement enregistré"){
                    alert("Incident enregistré avec succès");
                    videForm();
                    document.location.href="/listeTaches/attribTaches";
                }else{
                    $('#statut').html(rep.Message);
                }
            },
            error:function(XMLHttpRequest,error,errorThrown){
                alert(XMLHttpRequest.responseText+"///"+error+"///"+errorThrown);
            }
        })
    }else{
        alert("Vous devez choisir un incident");
    }
}
var bool=false;
function displayOrHide(id){

    if(bool==true){
        document.getElementById(id).style.display='block';
        bool=false;
    }else{
        document.getElementById(id).style.display='none';
        bool=true;
    }
}



function init(){
    displayOrHide("declareincident");
}

function videForm(){
    document.getElementById("idPal").value="";
    document.getElementById("qteArticle").value="";
    document.getElementById("idArticleFour").value="";
    document.getElementById("qteArticle").value="";
}

function cacheBouton(){
    switch(document.getElementById("sauveprofil").value){
        case "2" :
        case "4" :
        case "6" :
            document.getElementById("btnCariste").style.display='block';
            document.getElementById("btnUser").style.display='none';
            document.getElementById("btnChef").style.display='none';
            break;
        case "3" :
        case "5" :
        case "7" :
            document.getElementById("btnCariste").style.display='none';
            document.getElementById("btnUser").style.display='block';
            document.getElementById("btnChef").style.display='none';
            break;

        case "9" :
        case "10" :
        case "11" :
            document.getElementById("btnCariste").style.display='none';
            document.getElementById("btnUser").style.display='none';
            document.getElementById("btnChef").style.display='block';
            break;
    }
}